/**
 * @description 定义首页的接口
 */

import { HOME_RECOMMEND_URL, HOME_TYPES_URL, CART_LIST_URL, CART_MODIFY_URL, CART_Add_URL, CART_DELETE_URL, ORDER_ADD_URL } from "../config/urls.cfg";
import request from "./ajax";

/** 获取首页类型数据接口 */
export function homeTypesApi(): Promise<any> {
    return request({ url: HOME_TYPES_URL })
}

/** 获取首页推荐商品数据接口 */
export function homeRecommendApi(page: number, size: number): Promise<any> {
    return request({
        url: HOME_RECOMMEND_URL,
        params: { page, size }
    })
}
// 添加购物车
export function cartAddApi(data: any) {
    return request({
        url: CART_Add_URL,
        method: 'POST',
        data
    })
}
/** 购物车列表接口 */
export function cartListApi(uid: string) {
    return request({ url: CART_LIST_URL + uid })
}

/** 修改购物车产品的数量的接口 */
export function cartModifyApi(data: CartModifyObj) {
    return request({
        url: CART_MODIFY_URL,
        method: 'POST',
        data
    })
}
/** 新增订单接口 */
export function orderAddApi(data: any) {
    return request({
        url: ORDER_ADD_URL,
        method: 'POST',
        data
    })
}


/** 删除购物车的产品接口 */
export function cartDeleteApi(data: CartDeleteObj) {
    return request({
        url: CART_DELETE_URL,
        method: 'DELETE',
        data
    })
}